# 存放元素
import allure
from selenium.webdriver.common.by import By
from base.base_page import Basspage


# DEV宪章
from utils.assert_util import assert_compare


class OWS_DEV(Basspage):
    """关于登录页面元素"""
    # 手机号
    ows_mobile = (By.XPATH, '//*[@id="app"]/div[1]/div/div[2]/div/div[1]/div[2]/form/div[1]/div/div/div[1]/input')
    # 验证码
    ows_verification_code = (By.XPATH, '//*[@id="app"]/div[1]/div/div[2]/div/div[1]/div[2]/form/div[2]/div/div/input')
    # 登录按钮
    ows_login = (By.XPATH, '//*[@id="app"]/div[1]/div/div[2]/div/div[1]/div[2]/form/div[3]/button/span')
    # 断言登录成功是否==姜海欧
    up_jianghaiou = (By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[1]/div/div[3]/span[4]/div/div[1]/span[2]/a')


    """搜索Id及客户名称"""
    # 点击万能查
    ows_all_powerful = (By.XPATH, '//*[@id="app"]/div[1]/div[1]/div[1]/div/ul/div[2]/a/span/span[2]')
    # 光标放到搜索栏
    ows_search = (By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[2]/div/div/div[1]/div/div/div/div[2]/div[1]/div/div[1]/input')
    # 搜客户
    ows_id = (By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[2]/div/div/div[1]/div/div/div/div[2]/div[1]/div/div[2]/div[1]/div[1]/button/span')


    """创建报价单"""
    # 点击创建报价单
    ows_offer_quote = (By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[2]/div/div/div[4]/div[1]/div[2]/table/tbody/tr/td[10]/div/div/a/span')
    # 光标定位到订货号
    ows_location1 = (By.XPATH, '//*[@class="wtHolder"][1]/div/div/table/tbody/tr[1]/td[8]')
    ows_location2 = (By.XPATH, '//*[@class="wtHolder"][1]/div/div/table/tbody/tr[2]/td[8]')
    ows_location3 = (By.XPATH, '//*[@class="wtHolder"][1]/div/div/table/tbody/tr[3]/td[8]')
    # 双击订货号列表
    ows_double_click = (By.XPATH, '//*[@id="app"]/div/div[2]/div[2]/div/div/form/div/div[2]/div/div/div[2]/div/div/div/div[6]/textarea')
    # 点击匹配
    ows_matching = (By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[2]/div/div/form/div/div[2]/div/div/div[3]/div/div/button[2]/span')
    # 点击清空
    ows_delete = (By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[2]/div/div/form/div/div[2]/div/div/div[3]/div/div/button[1]/span')
    # 点击转订单
    ows_orders = (By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[2]/div/div/form/div/div[5]/div/div/div[3]/div[1]/button/span')
    # 断言it测试品牌
    ows_itoa = (By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[2]/div/div/form/div/div[4]/div[2]/div[2]/div[1]/div/div[1]/div[2]/table/tbody/tr[1]/td[8]/div/form/div/a[2]')



    """确认订单页面"""
    # 不开发票
    ows_no_invoice = (By.XPATH, '/html/body/div[41]/div[2]/div/div/div[2]/div/div[2]/div[1]/div[3]/div[2]/div[2]/label')
    # 支付方式微信支付
    ows_wechat = (By.XPATH, '/html/body/div[41]/div[2]/div/div/div[2]/div/div[2]/div[1]/div[7]/div[2]/div[1]/label')
    # 备注
    ows_remark = (By.XPATH, '/html/body/div[41]/div[2]/div/div/div[2]/div/div[2]/div[1]/div[8]/div[1]/div/textarea')
    # 提交订单
    ows_order = (By.XPATH, '/html/body/div[41]/div[2]/div/div/div[2]/div/div[2]/div[2]/div[2]/div[2]/a')
    # 确定订单页面，断言客户名称、联系人
    ows_name = (By.XPATH, '/html/body/div[41]/div[2]/div/div/div[2]/div/div[1]/div[1]/div[1]/span[2]')
    ows_concoct = (By.XPATH, '/html/body/div[41]/div[2]/div/div/div[2]/div/div[1]/div[1]/div[2]/span[2]')


    """报价单转订后弹窗提示转单成功，断言"""
    # 转单成功
    ows_order_succeed = (By.XPATH, '/html/body/div[42]/div[2]/div/div/div[1]/div')
    # 客户姓名
    ows_client_name = (By.XPATH, '/html/body/div[42]/div[2]/div/div/div[2]/div/div/div[1]/div[1]/div/span[2]')

    # 登录
    def __init__(self, driver):
        super().__init__(driver)
        self.implicitly_wait = None

    def dev_login(self):
        self.get("https://ows.yesmro.cn/")
        self.send_keys(self.ows_mobile, "18910937339")
        self.send_keys(self.ows_verification_code, "937339")
        self.click(self.ows_login)
        jianghaiou = self.get_text(self.up_jianghaiou)
        assert_compare("姜海欧", '==', jianghaiou)